import 'package:flutter/material.dart';
import "package:get/get.dart";

class Rate extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Color(0xffffffff),
        leadingWidth: 40,
        leading: IconButton(
          onPressed: () {
            Get.back();
            print('object');
          },
          icon: Image.asset('static/images/back.png'),
        ),
      ),
      body: Container(
        margin: EdgeInsets.only(left: 15, right: 15),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '今日汇率',
              style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold,),
              textAlign: TextAlign.start,
            ),
            SizedBox(height: 20),
            Text(
              '1 美元 ≈ 7.1277 人民币',
              style: TextStyle(fontSize: 16),
            ),
            SizedBox(height: 5),
            Text(
              '1 人民币 ≈ 0.1403 美元',
              style: TextStyle(fontSize: 16),
            ),
            SizedBox(height: 20),
            ExchangeRate(),
            SizedBox(height:20),
            Align(
              child:Image.asset('static/images/zhuang.png',width: 14,),
            )
            ,
            SizedBox(height: 20),
            ExchangeRates(),
          ],
        ),
      ),
    );
  }
}

class ExchangeRate extends StatelessWidget {

  TextEditingController _controller = TextEditingController();

   ExchangeRate({super.key});

  @override
  Widget build(BuildContext context) {
    return 
    GestureDetector(
      onTap: (){
        Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
      },
      child: Container(
      height: 53,
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 0),
      decoration: BoxDecoration(
        color: Color(0xfff5f5f5),
        borderRadius: BorderRadius.circular(25.0),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(
                'static/images/usd.png', // 替换为你的图片路径
                width: 25,
                height: 16,
                fit: BoxFit.fill,
              ),
              SizedBox(width: 5),
              Column(
                children: [
                  SizedBox(height: 10),
                  Text('美元',
                      style: TextStyle(fontSize: 12, color: Color(0xff333333))),
                  Text('USD',
                      style: TextStyle(fontSize: 12, color: Color(0xff333333))),
                ],
              ),
              SizedBox(width: 10),
              Image.asset(
                'static/images/xia.png', // 替换为你的图片路径
                width: 12,
                fit: BoxFit.fitHeight,
              ),
            ],
          ),
          // 将原本的 Text('1') 替换为输入框
          SizedBox(
            width: 80, // 限制输入框宽度
            child: TextField(
              controller: _controller,
              keyboardType: TextInputType.number, // 设置键盘为数字键盘
              textAlign: TextAlign.right, // 文本右对齐
              style: TextStyle(fontSize: 20),
              decoration: InputDecoration(
                border: InputBorder.none, // 隐藏输入框默认边框
                hintText: '0', // 提示文本
              ),
            ),
          ),
        ],
      ),
    ),
    )
    ;
  }
}

class ExchangeRates extends StatelessWidget {

  TextEditingController controller = TextEditingController();

   ExchangeRates({super.key});

  @override
  Widget build(BuildContext context) {
    return 
    GestureDetector(
      onTap: (){
        Get.dialog(
                AlertDialog(
                  backgroundColor: Colors.transparent,
                  content: Stack(
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.circular(15.0),
                        child: Image.asset(
                          'static/qidai.png',
                          width: 250,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ],
                  ),
                ),
              );
      },
      child:Container(
      height: 53,
      padding: EdgeInsets.symmetric(horizontal: 16, vertical: 0),
      decoration: BoxDecoration(
        color: Color(0xfff5f5f5),
        borderRadius: BorderRadius.circular(25.0),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Image.asset(
                'static/images/cny.png', // 替换为你的图片路径
                width: 25,
                height: 16,
                fit: BoxFit.fill,
              ),
              SizedBox(width: 5),
              Column(
                children: [
                  SizedBox(height: 10),
                  Text('人民币',
                      style: TextStyle(fontSize: 12, color: Color(0xff333333))),
                  Text('CNY',
                      style: TextStyle(fontSize: 12, color: Color(0xff333333))),
                ],
              ),
              SizedBox(width: 10),
              Image.asset(
                'static/images/xia.png', // 替换为你的图片路径
                width: 12,
                fit: BoxFit.fitHeight,
              ),
            ],
          ),
          // 将原本的 Text('1') 替换为输入框
        
          SizedBox(
            width: 80, // 限制输入框宽度
            child: TextField(
              controller: controller,
              keyboardType: TextInputType.number, // 设置键盘为数字键盘
              textAlign: TextAlign.right, // 文本右对齐
              style: TextStyle(fontSize: 20),
              decoration: InputDecoration(
                border: InputBorder.none, // 隐藏输入框默认边框
                hintText: '0', // 提示文本
              ),
            ),
          ),
        ],
      ),
    ) ,
    )
    ;
  }
}
